Errata for The C++ Programming Language
Table of Contents
http://www.math.pku.edu.cn/teachers/qiuzy/books/cppl/3rd_printing16.htm
Errors and Clarifications
Chapter 1:
pg 13 s/(sec B.2)/(with a few minor exceptions; see sec B.2)/
Chapter 2:
Chapter 3:
Chapter 6:
pg 134: s/``does p point to a valid object,''/ ``does p point to a valid object (assuming proper initialization),''/
Chapter 10:
pg 251 replace the middle example with void g() { vector< Table> v(10); // no need for a delete vector< Table>* p = new vector< Table>(10); // use plain "delete" rather than "delete[]" delete p; } Using a container, such as vector, is simpler than writing a new/delete pair. Furthermore, vector provides exception safety (Appendix E). Chapter 11: pg 290 replace the example using Y at the middle of the page by: Given a class Y for which ->, *, and [] have their default meaning and a Y* called p then p->m == (*p).m // is true (*p).m == p[0].m // is true p->m == p[0].m // is true Chapter 13: pg 335 s/const char[12]/const char v[12]/
Chapter 14:
pg 369 better: X* p3 = new(&buffer[10]) X; // place X in buffer (no deallocation needed) X* p4 = new(&buffer[11]) X[10]; Chapter 18: pg 538 replace the second example with For a call random_shuffle(b,e,r), the generator is called with the number of elements in the sequence as its argument: r(e-b). The generator must return a value in the range [0,e-b). If My_rand is such a generator, we might shuffle a deck of cards like this: void f(deque< Card>& dc, My_rand& r) { random_shuffle(dc.begin(),dc.end(),r); // ... }
Chapter 20:
pg 599: replace the last two declarations with: size_t strspn(const char* p, const char* q); // number of char in p before a char not in q size_t strcspn(const char* p, const char* q); // number of char in p before a char in q
Appendix A:
Appendix B:
Appendix C:
pg 895 s/: num_put/std::num_put/ pg 898 s/my_numpunct/My_punct/ pg 910 add before D.4.4.4: A _byname version (D.4, D.4.1) of time_put is also provided: template < class Ch, class Out = ostreambuf_iterator< Ch> > class std::time_put_byname : public time_put< Ch,Out> { /* ... */ }; pg 912 s/time_put()/time_put::put()/ twice pg 912 replace the last paragraph with: A _byname version (D.4, D.4.1) time_get is also provided: template < class Ch, class In = istreambuf_iterator< Ch> > class std::time_get_byname : public time_get< Ch,In> { /* ... */ }; pg 915 s/Date_format< char>::/Date_format::/ pg 918 s/dateorder()/date_order()/ pg 919 s/order = dateorder();/order = date_order();/ pg 919 s/tmp->tm_mday = val[1];/tmp->tm_mday = val[2];/ pg 924 s/widen(narrow('x')) == 'x'/widen(narrow('x'),0) == 'x'/ pg 926 s/out() encountered/in() encountered/ pg 928 add "char ch;" before the while-statement
Appendix D:
Appendix E:
Typos
Chapter 4:
pg 80 s/a vector/an array/
Chapter 11:
pg 288 s/ of the array/of the vector/
Appendix B:
pg 817 s/Direction d = 1;/enum Direction d = 1;/